#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int differenceOfSum(int* nums, int numsSize)
{
	int elemsum = 0;
	int numsum = 0;
	for (int i = 0; i < numsSize; i++)
	{
		elemsum += nums[i];
		while (nums[i])
		{
			numsum += nums[i] % 10;
			nums[i] /= 10;
		}
	}
	return abs(elemsum - numsum);
}
int main()
{
	int nums[30] = { 0 };
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &nums[i]);
	}
	printf("%d", differenceOfSum(nums, n));
	return 0;
}